
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

public class FishingMod {

    protected static final Logger log = Logger.getLogger("Minecraft");
    private static FishingMod instance;
    private FishingDataSource dataSource;
    private PropertiesFile properties;
    private String fishingLocation, bucketLocation;
    private String source;

    public static FishingMod getInstance() {
        if (instance == null) {
            instance = new FishingMod();
        }
        return instance;
    }

    public FishingDataSource getDataSource() {
        return dataSource;
    }

    private FishingMod() {
    }

    public void load() {
        if (properties == null) {
            properties = new PropertiesFile("server.properties");
        } else {
            properties.load();
        }

        try {
            fishingLocation = properties.getString("fishinglocation", "fish.txt");
            bucketLocation = properties.getString("bucketlocation", "bucket.txt");
            source = properties.getString("data-source", "flatfile");
        } catch (Exception ex) {
            log.log(Level.SEVERE, "Exception while reading book mod properties", ex);
        }
    }

    public void loadData() {
        if (source.equalsIgnoreCase("mysql")) {
            dataSource = new FishingMySQLSource();
        } else if (source.equalsIgnoreCase("flatfile")) {
            dataSource = new FishingFlatFileSource();
        }
        dataSource.initialize();
    }

    public String getFishLocation() {
        return fishingLocation;
    }

    public String getBucketLocation() {
        return bucketLocation;
    }

    public int getFishChance() {
        return dataSource.getFishChance();
    }

    public List<Fish> getFish() {
        return dataSource.getFish();
    }

    public List<Bucket> getBucketList() {
        return dataSource.getBucketList();
    }

    public Bucket getBucket(String name, int item) {
        return dataSource.getBucket(name, item);
    }

    public List<Tier> getTier() {
        return dataSource.getTier();
    }
}
